If someone forgot to open bottles before shabbos. He can then open them if the caps are punctured. Can a hammer and nail be used since the plastic is thick? If so, can the hammer and nail be returned to the tool box?
Yes, there is no problem in using a hammer and nail to pierce a bottle cap, if this is required for opening the bottle on Shabbos.
The reaons for this is that hammers and nails are only mukzeh because there are used for prohibited practices (keli shemelachto le’issur), and therefore there is no problem of moving them and using them where there is a need.
Note that some authorities maintain that it is permitted to open plastic caps on Shabbos; we have discussed this issue here: https://dinonline.org/2011/09/14/opening-bottlescans-on-shabbos/.