I… super hesitate to wade into this, but:
1) It was way before it became prestigious.
And
2) An explanation of this needs to account for a great and rapid shift in favor of women, as far as proportion-of-practitioners, that was happening at exactly the same time as the opposite shift in programming, in both law and medicine.
I don’t know what the actual reason is but “it got prestigious so women got pushed out” makes no sense to me, based on the timeline of events in full context. It was very much not prestigious in the ‘80s and early ‘90s, certainly far less so than law and medicine at that time (still isn’t as prestigious as those, outside tech circles—you can see it in people’s faces. It’s high-paid but lower-“class” than those, to this day)
The traditional way I heard it wasn’t that it was about prestige, but rather that programming became engineering-coded rather than humanities-coded. And misogyny did play a role there, one of the Turing movies had a great story line about it, although I can’t remember the name off hand.
Related, I think math went through a similar transition.
As others have pointed out, prestigious is too strong of a word, what I actually meant was "a job a man could be seen as doing".