The studios know what makes money and what doesn't make money.
Movies about crime make money.
Was their every a movie about the mob where the lead was able to walk a way with money, and not get caught? I can't remember one.
I wish there were I like the bad guys winning.
I was hoping the character in Breaking Bad would beat cancer. Take his 80 million and get out, and open his car wash keep his family and live happily ever after.
I don't know about America, but in Italy there are plenty of mafia movies (especially those made before the 2000s) where the "good guys" lose and the mafia/corrupt politicians/secret services win. For example, in most Damiano Damiani's movies there is a clear and realistic message that single people can't beat the corrupt system.
As for idolizing mobsters in movies, I think that in many cases it's due to misunderstandings by the viewers of the author's intentions. For example, the scene in the Godfather where Michael "renounces" his sins in a church and at the same time his hitmen whack everybody, I think this is a powerful scene which clearly shows the hypocrisy and ruthlessness of the mafia and how Michael betrayed his original ideals. Nevertheless, many people consider Michael as a "cool" character to be sympathized with, probably even admire how he managed to wipe out all rivals at once.
I personally like watching mafia movies, especially realistic ones, as illustrations for certain historical periods, but that doesn't mean I like the protagonists from a human point of view; in the Godfather I wished everyone to fry on the electric chair.