walk, run takes 40 minutes total, 12 come from running on the way back
So the walking must take 28 minutes.
walk, walk takes 28$\times$2 = 56 minutes.
Using algebra
If it takes John $w$ minutes to walk to (or from) school and $r$ minutes to run to (or from) school, then we have $$\begin{align}r+w&=40\\2r&=24\\2w&=?\end{align}$$
Finding $r$ first
$2r=24\Rightarrow r=12.$ Substituting this into $r+w=40$ gives $12+w=40\Rightarrow w=28.$ So $2w=2\times28=56.$ So it takes $56$ minutes to walk both ways.
Doubling the first equation
Doubling both sides of $r+w=40$ gives $2r+2w=80.$ Since $2r=24,$ $24+2w=80\Rightarrow 2w=80-24=56.$ So it takes $56$ minutes to walk both ways.