He suffered 40% burns when he either touched overhead cables or the current "jumped" from the nearby line.
His friend tried to help by pushing him away from the current but got shocked himself, BTP said.
The pair, both 13, were trespassing in a railway depot in Wednesbury, West Midlands, on 1 June.
Releasing more details of what happened, police said the boys had entered the depot through an unauthorised access point in the depot's fence.
"Once on the site, one of the boys got on top of a freight train," a statement said.
"At this point, he either came into contact with an overhead electricity cable or the current - which can jump 3m (9.8ft) from the line to nearby objects - arced, transferring 25,000 volts through his body and resulting in 40% burns.
"The other boy went to help by pushing him away from the current but in touching him, also received an electric shock."
Both were airlifted to a Birmingham hospital where one boy remains.
Insp Jacqui Wilson, from BTP, said one boy was "extremely" lucky to be alive and warned others to be aware of the dangers railways pose.
"We are also not apportioning blame but simply setting out the risks to try and stop others from taking them," she said.
Officers are now patrolling the area and leafleting to stop trespassers.
After a recent rise in people getting into the site, the parents of one of the boys had already warned their son about the dangers of playing there, police said.
One of two boys electrocuted while playing near train tracks was hit with 25,000 volts, British Transport Police (BTP) said.