Dead asteroids, space junk, asteroid fields, and magnetic storms are always undefended. Asteroids always have one TEC siege frigate and one light frigate. Ice, volcanic, terran, and desert planets have random numbers and types of defenders (always TEC units). They always have at least one siege frigate, and may also have light frigates, long range frigates, flak frigates, and heavy cruisers. Typically 6-12 units defend these planets types, and up to four of any kind may appear. Gas giants and plasma storms are always defended by one pirate light frigate and one pirate flak frigate.
These defenders won't chase you if you leave their gravity well, and will always prioritize their attacks against a colony frigate. They're a great way to level up your first capital ship, even if you don't intend to colonize the planet yet. When deciding where to colonize early on, sometimes it's a good idea to take a look at how many defenders (and of what type) are in each planet. If you see lots of heavy cruisers, you might want to save that one for later. If you just see light frigates and siege frigates, it's easy pickings.