Gadgets are expensive weapons used to fight against Doofenshmirtz. You need three of them to make sure that you can actually fight back. Do not focus on purchasing gadgets. Instead, collect as many coins as possible and get other upgrades to the first level. If you can avoid his weapons long enough, Doofenshmirtz will disappear. However, the second mission requires you to have a gadget.