How to prevent erroneous wire connection to a through hole component, eg. a pin header?

While drawing the connections to a through hole component (like pin header), we can accidentally connect the wires on the wrong side (i.e. not the side that we solder). How do we prevent this?

For example I can connect both Front copper and Back copper to a pin header, which is clearly wrong (as we can not solder both sides):

Your question is not clear…
The tracks in pcbnew are in copper, so as long as you make/get made a 2 layer board the connections will be there in the copper. Soldering the components into the through holes will connect them with the copper, be it on front or back.
So, yeah, your question doesn’t make sense.

Do you mill a 1 layer board?
If so, just use one side of the copper, either back or front, don’t switch.
There is no ‘global’ setting in pcbnew that allows only ‘laying’ tracks on front or back only, if that’s your question… you have to make sure of that yourself.

Do you assume that all holes are plated? We don’t plate the holes most of the times, so if we don’t connect the wire to the side which we don’t solder, then the wire may or may not be connected the pin. That’s the case actually.

So, you’re talking DIY developed boards without plating?

Well, as I wrote above… you, the layouter, needs to make sure to connect the pads/holes on the single side that works for you.
You could switch off the visibility of the unused copper layer on the right hand panel, to aid you in that.

PS: it seems hard coded…

Yes, I exactly meant the development/prototype boards.

So I understand that there is no way other than carefully drawing the routes. Thank you.

What happens if you set a layer to “jumper”?