The power dissipated in a linear regulator is the difference between the input and output voltage times the current. So just to use 1 A as an example, the top 7805 would dissipate \$(24 V - 5 V) \times 1 A = 19 W \$ and the bottom one would be \$(12 V - 5 V) \times 1 A = 7 W \$
The problem then is that the other 12 W would end up being added to the dissipation of the 12 V regulator. The power to drop from 24 V to 5 V has to get dissipated somewhere, by going with the second schematic you're just shifting some of it from one regulator to the other.
From your comments it appears that you're already at 9.6 W on the 12 V regulator, so add whatever current the 5 V regulator needs times 12 V and that will give you the additional power the 12 V one will have to handle.
You can find how much current you actually need at each voltage and calculate the dissipation for both cases to see if it's possible to stay within the specified ratings of the regulators. Alternatively you could use switching regulators which will be much more efficient and won't have this \$E \times I\$ loss.
Note that the current for each regulator includes its quiescent current. In addition to the current drawn by the load there is also a small current to run the regulator and that contributes to its power dissipation. It's usually small enough to be ignored but you should take a look at it anyway.