So first, people still do things wrong all the time.
But as an answer to your question-I started training at like 3/4. The first 15/20 years I trained under people who became pickier about my technique, and would point out whenever my technique was bad. I know they did so accurately by seeing their changes to others' technique. I also had mirrors around me for the most part, so I could see the results. I could also feel if things were working through drills and light & full contact sparring-if it didn't work, either I was doing something wrong, or the technique was bad. If it did work, that probably means my technique is good. There are also drills that only work if you do the tech correctly. (I think I mentioned on here one with a wall to make sure your elbows aren't flaring before).
Then I also started training with people of a lot of different styles, while crosstraining as well, and sparring those people. This provided more feedback when new teachers would look at my tech and I could also try them against people from different styles.
At some point, I reached a point where I can 'feel' when techniques aren't right. It's tough to explain but your body just knows when you're doing it wrong. That might be a result of synaptic pruning/'muscle memory', might be just that muscles or more sensitive to unnatural/harmful movements, I'm not sure. I still get (or got before this year) feedback on my tech, as when you go too long without feedback (or video if you don't have feedback as an option), your habits can change a bit, but for the most part this year I've been trusting my body and ability to have proper technique.