You will get 24V, but it will not be 24V with respect to the ground connection.
Voltage is a difference.
In this case the difference between ground and +12V is 12V, and the difference between ground and -12V is also 12V, but in the opposite direction.
So, the difference between -12V and 12V is 24 volts (12V to get from -12 to ground, plus another 12V to get from ground to +12V)
It's a bit like if you live on a straight road running north-south. One of your friends lives 12 miles north of you, the other 12 miles south of you. Thus they are 24 miles apart.