All those are good questions.
How did a teenager acquire the weapon?
In the state of New York the existing laws allow an 18-year-old to buy guns without a permit. That kid bought weapons, a shotgun and a semi-automatic AR-15-style gun, an imitation military weapon, along with abundant ammunition and body armor. It was legal on paper, but clearly the wrong thing to do.
How did he get the money to pay for it?
According to newspaper accounts (this morning's Washington Post) he bought & sold silver coins to fund his purchases. I don't know how he got the starter cash to begin doing that.
And more importantly, why did the gun dealer sell to a teenager in the first place?
The existing laws allow that. Months earlier, while still in high school, he had been held, at the order of NY State Police, in a hospital mental facility under scrutiny for threatening to commit 'murder-suicide'. After a day and a half, he was released, apparently after lying his way out. The gun shop owner says he ran the kid's name through a required background check. After that check showed nothing to prevent the sale, he sold the gun to the kid. I don't understand whether New York state law includes such an episode as a reason to prevent him from buying guns.
Obviously, that background check failed to prevent a mass murderer from legally obtaining lethal weapons. It is common in the USA to run some kind of perfunctory background check before selling weapons, but most of them are designed to be more lip-service than effective. This is most often the result of undue political influence by the National Rifle Association, a political lobby group that claims to represent gun owners, but really represents gun manufacturers and sellers.
Or, if the gun was in the family home, why wasn't it secured safely, i.e. a gun safe?
The kid apparently lied to his parents about his plans and activities. He kept all his purchases hidden from them. After his high school episode, they might have sensed something wasn't right, but he kept them from knowing anything more incriminating.
I feel sorry for them. Most parents of teenagers in the US try their best to provide good examples for their kids as they grow up. And they hope their kids don't grow up to be axe murderers. In this case, their worst fears came true.