Police allege the 15-year-old found the keys to his father's gun safe and took two rifles from inside before heading to Atlantis Beach Baptist College in Two Rocks.
He only shot one gun, a .234 rifle used for hunting, before panicking and calling the police himself, 9News can reveal.
A nearby demountable classroom with school kids inside was hit by the bullets, but no one was injured.
"It was a very fraught situation ... we are very lucky no one was killed, so the bullets went close so it's a terrible, terrible thing and it could have been so much worse," WA Premier Mark McGowan said.
Police allegedly found more than 60 rounds of ammunition and two long-armed rifles inside a black four-wheel drive found at the school.
The teen's neighbours told 9News the 15-year-old was growing increasingly anti-social recently.
"He was really nice until the last year and a half," they said.
"He just started to [grow] quieter and quieter, and only keep to one or two people, his friends."
The teen's father has been questioned by Police, and his rural family home has been searched by investigators.
The teen has been charged with driving without authority, possessing a firearm and ammunition without a licence, discharging a firearm in a manner to cause fear, possessing a prohibited weapon and acting unlawfully with intent to harm.
He will appear before the Perth Children's Court on Friday.
Sign up here to receive our daily newsletters and breaking news alerts, sent straight to your inbox.