I fly Il-2's a lot and get shot down by tank main guns occasionally. I don't come diving down in steep angles on tanks to fire on them for several reasons. First is that I need to be firing at close range to see the target, to hit it, and to penetrate, and pulling out under those conditions isn't usually too workable. Second is that if I'm not down in among the trees, Wirbles can nail me easily as I'm scouting around for things. Third is that it takes a while to climb back up, position, etc., compared to staying low.
Not all tankers hit me going in. Some are very good (like BaldEagle and Tyfoo as a couple examples), but most people are not perfect shots. Still, if the guy is a good shot, on my next life, I'm more careful and try feinting or jinking in, waiting for the shot, then trying to get in before they reload, or I try harder to come in with a larger angle, or I try to coordinate with another attacker.
I do suspect it was not as easy in real WWII tanks to shoot airplanes out of the sky, especially in tanks that are maneuvering as they shoot at you. But I don't know for sure, and it doesn't bother me much. It's still fun to go after tanks with Il-2's, flying around at treetop level.