Napoleon tried taking spain, it was nearly his undoing. It would be like the US annexing Canada in the middle of a war. Yes we are friendly now, but the first truckload of troops over the border would change that.
Plus have you ever looked at spain?
All those mountains, terriblle place to try to move troops through quickly.
At the same time a wonderful place for an unhappy populace to use guerilla warefare against an intruder.
To truly seal the Med Hitler would have had to have captured ships of either France & Italy, plus captured Gibralter itself.
Germany itself simply lacked the ships to do the job, and what ships it had were locked in place up North.
Once done what does he really gain. Granted he'd of been better able to resupply North Africa. But North Africa really brings no wealth of resources along with it.
If you want to "what if" Look instead at what would happen if Hitler had used a bit of paitence. Say he didn't move against poland until 43, or 44 when he was really ready. France & the low country's fall shortly after. He's had several years to build uboats, & surface ships, so now he is truly able to starve England into submission.
With no foothold for the US troops to muster he can now turn his attention to Russia.