The tank needs to be cycled first. Aquariums are whole eco-systems that need beneficial bacteria to help break down the fish waste so they don't burn their gills.
I don't suspect that is what happened to your fish though. Given how fast they passed, I'm suspecting they died from water shock.
If you did not test the water, condition it, or acclimate the fish from the water they came in to the water from your tap, then the PH difference, temperature difference, and metals and chemicals in your water likely killed them. It is very important when buying new fish to test your water and get the parameters to as close to what they need as possible, and then acclimate them slowly.