If you pay attention teams go for 4th downs far more than was common 20-25 years ago often regardless of field position, distance and score. Analytics have dramatically changed all sports the few decades and the pace of change has quickened.
Yes, but.
Football, all else being equal, is a game of emotion. Any good coach will weigh not only the analytics but the psychology of a decision.
Let’s say for the sake of discussion that the analytics say throwing 4 straight bombs gives you a 90% chance of scoring a touchdown. But if your quarterback is having confidence issues then the impact of coming up with zero points after 4 straight throws to the end zone would be psychologically devastating and he will probably be no good to you for the rest of the game. Better to put him in that situation at the end of the game with nothing left to lose. If he comes up with zero then it is understandable and something he can get over quickly before the next game.
Whether going for 2, onside kicks, going for it on 4th down, or any other move, you have to weigh the mental state of your team, whether they have the confidence to pull it off and what the psychological impact will be if they make it or if they don’t make it. Likewise, it is good to consider the same factors with your opponent, everything from how much confidence they are playing with to what the impact will be on them if you pull it off or don’t pull it off.
In my life time there were two coaches who were masters of psychology- Bobby Dodd and Vince Lombardi. The psychological impact of a calling a certain play or making a certain coaching decision was a huge factor in their success.