This involves the explanatory の, which is used to fill in information missing from a situation.
Consider the following sentence:
「商品として置いてた金庫だ」
This is a statement: “It is a safe placed out (on a shelf) as a product (to sell).”
The reason he’s saying this is to explain the situation of the safe. Prior to this, Saitou and the kids already were aware that there was a safe, but they didn’t know why there was a safe.
When taking a situation with incomplete information (there’s a safe, but why is there a safe?), and adding in the missing information (this is why there is a safe), Japanese has specific grammar for this. This is done by turning the sentence into a noun, and adding だ, resulting in a noun sentence that reads as 「It is (sentence).」 Here, “it” refers to the missing information which is being presented.
Adding の+だ to this results in:
「商品として 置いてた 金庫だのだ」
However, this is not proper grammar. Instead, that original だ becomes な:
「商品として 置いてた 金庫なのだ」
Now we have proper grammar.
In speech, it’s common for this の to be pronounced as ん:
「商品として 置いてた 金庫なんだ」
This changes the sentence from simply a statement of fact, to a statement that fills in the missing information: “It is that it is a safe placed out (on a shelf) as a product (to sell).”
As is common when comparing Japanese with English, we don’t quite have this structure in English. (Starting an English sentence with “It’s because…” is very close, though.) For the most part, this is something you’ll get used to over time, so long as you take notice of のだ and (な)のだ and their spoken counterparts んだ and (な)んだ, and ask yourself, “What is the partial information, where this のだ line is the missing information being provided (or asked for)?”
Edit: Just to be sure, I should mention so that 「商品として 置いてた」 is a modifier for 金庫. It’s giving information about the 金庫. Rather than simply “a safe”, it’s “a safe that was placed out (on the shelf) as a product (to sell)”. If you see a verb followed by a noun, it means the noun is being modified by the clause (partial sentence) that ends up that verb.