@cammerman The choice is to pay up front to write code properly or pay much more when it's too late, if the code survives that long. The companies I worked for understood this, but I know not every company does.
I wonder if the bad practice you describe is more prevalent in application software? If you are developing libraries and tooling, for example, poor quality really costs a lot when users hit problems and these need diagnosing and fixing.