In Infinity War, Black Widow fights against Thanos' female henchman (or henchwoman, I guess). They have a stand off in which they lock staves and are pushing against each other, and neither seems to have a real advantage. Presumably, Thanos' agent has strength above that of a normal human (see the fight with Vision and Scarlet Witch). There is no indication in the MCU that Black Widow has any superhuman abilities (Hawkeye has a pretty even fight with her in the first avengers movie) so how could she hold her own in that clash?
Black Widow fights Proxima Midnight twice in the movie--once in Europe early on, and once in Wakanda in the climax of Infinity War. I'm going to assume you mean the latter, in that as far as I can tell, she barely trades a blow with Midnight in the former--Captain America meets her spear-to-spear. (Nat does soundly beat Corvus Glaive, which is another whole debate.)
In Wakanda, Midnight does go to cut Widow's throat with an oversized wrist dagger, and Widow blocks it. But Midnight is in the middle of a fight, probably slightly winded, and going for a killing blow--probably not using her full strength. And Black Widow holds her back for all of a second before Wanda intervenes.
Which brings up what I think is something of the true question here--"How does Black Widow, a bog-standard human, fight against giant alien badass chick Proxima Midnight?" Widow was never fighting to win--she's fighting to buy time until Wanda recovers, and Wanda using her powers is basically an "I win" button.
As noted in comments, Natasha Romanov is a "peak human" -- about as physically capable as any woman her size can be (due to accident of birth plus long term rigorous training). Beyond that, she has "heart" -- an absolute unwillingness to give up or admit defeat. She has an extreme level of training in unarmed and hand weapon combat, and a willingness (likely partially natural, partially trained) to "fight dirty" -- using any tactic or tool available to win (as, in Avengers Assemble, when she "reset" Clint's brain to let him recover from the programming he had received from the Tesseract).
Combine these traits and you have one of the best defenders humankind could ask for -- and someone who could beat someone significantly more powerful, if they lack the level of commitment and training she has.
She didn't is the short answer.
If you look closely at the scenes in Avengers: Infinity War, she never fights Proxima Midnight on her own. Not really.
There is never a real one-on-one fight between Proxima and Black Widow. In their first fight she is aided by Captain America. And if you look closely he is doing all the "heavy" stuff like locking staves with Proxima.
Black Widow only managed to hurt Corvus Glaive because they had the element of surprise on their side. She essentially sucker-punched or rather sucker-stabbed him.
In their second fight Black Widow is assisted by Okoye, probably a warrior as strong (in Marvel terms: peak human) as she is. Together they manage to hold of Proxima Midnight. For a while.
Eventually Okoye is overpowered. Black Widow manages to disarm Proxima Midnight but afterward Proxima literally beats her back with her bare fists!
At that point Proxima is close to killing Black Widow with her unable to do anything about it. Only Scarlet Witch's intervention saves her live.
As to why she was able to hold out even that long: aside from being a "peak human" she is an Avenger. She has both experience and training in fighting enemies of far greater physical strength then herself. She knows all the moves to mitigate or even nullify their moves.
Raw strength alone does nothing. Any student of the martial arts will tell you that.
According to the accepted answer to the question Is Black Widow genetically engineered or enhanced in Avengers?:
The Marvel Cinematic Universe (Earth-19999) has not given us a complete backstory on the Black Widow for their universe, but in the Marvel canon universe (Earth-616) she has had the equivalent of the Super-Soldier serum (a Russian variant) given to her making her the female equivalent to Captain America.
In the first Avengers movie, it could be she was holding back against Hawkeye since she didn't actually want to kill or permanently injure him.
Thus, the Infinity War fight may allude to the fact that in the Earth-19999 universe, she has also had the equivalent of the Super-Soldier serum. We may learn that fact in later background narratives.
In the 616 continuity (Mainstream Marvel) universe Natasha romanov underwent similar bio modifications as Captain America did. While not the SuperSoldier Serum invented by Erskine, she underwent a drug regimen gave her superior strength and agility for a woman her size who engages in intensive regular exercise. It also retards her physical aging slightly and boosts her healing slightly and immunity to disease However the consequence is she is incapable of bearing children; She is not infertile or sterile; her reproductive system simply views a fetus as foreign disease tissue.
In Earth 199999 (Cinematic) she is sterilized to prevent personal attachment; but had to undergo a rigorous bio modification regimen; as she is 39 years old by 2023.