It's possible to spawn units on top of mountains by having a building or ship nearby. It'd be nice if there was a check to ensure that you couldn't do that.
In this screenshot the water level was 19.9m and the unit's height was 24.6m, a difference of 4.7m. In the patch I use a threshold of 5m, so this gives a sense of scale.
Here's an example of spawning on a mountain on Empire. Units won't spawn above or below the barracks because the height difference is too big.
(I chose to ignore ships rather than dealing with water level and float depth and things like that.)