Hi Dave
When you download a program for OSX, it's normally in a file format called DMG, short for Disk Image. They are small mountable hard disk files, almost like a pretend CD-ROM or hard drive. If you have the correct settings in Safari, the DMG will mount automatically after the DMG is downloaded. You can also mount it manually by double clicking on the DMG icon.
Once mounted, you get a second icon on your desktop normally with the same name. Because of the way the Finder in OSX works, all mounted drives (even pretend ones) appear as icons on the desktop*. However, the applications are still inside the DMG file, it's just now you can see inside the DMG file because you have mounted it as a volume. As Eidorian mentions, to actually install the app natively onto your hard disk, you need to copy it out of the DMG file by dragging it to a location on your hard disk. The usual place to put it is your Applications folder.
Now the Dock. When you drag an application to the Dock, you don't move the application, you just create a shortcut to it's current location. In your example the Dock icon you created acted as a shortcut to Firefox, but Firefox was still in the DMG file rather than being on your hard disk. So when you dismounted the DMG file (which happens automatically when you reboot), the shortcut no longer worked.
When installing apps, always copy the application from the mounted Disk Image to your Applications folder, then drag the icon from your Applications folder to the Dock. You can then remove the Disk Image by dragging it to the trash, then lastly remove the DMG file by doing the same.
* The Show options in Finder Preferences can change this behaviour if you wish.