The easiest way is to kill the transports before they reach the planet.
Any ship in orbit will prevent an invasion until the orbit is empty. If you put ships there, the AI will send ships/fleets until the orbit is swept clear. SOmetimes, the AI fleet will have transports in it.
I have found that the AI often will send unescorted transports to planets w/o any defenders in orbit. One trick is to build a few very fast transport interceptors, and station them carefully. The idea is to have the interceptors able to spring past the undefended planet far enough to intercept the incoming transports while they are still over one turn away from your planets. Thus, you can try to empty the orbit and defend that way. If the AI sends an escorting fleet, you need to beat the escorts with regular ships.
Oh, and look carefully at the AI tranports not for just their speed, but also for armament, as sometimes thre AI slips sone weapons on the transports.
The transport interceptor trick is one way to combat the DreadLords themselves, as their warships are unbeatable until you tech up, but their transports are not.
If you cannot defend as above, the best defense is to max defense, of course, but also to have a planetary huge population and a very fast population growth rate. Most here can recount games where they had a superbreeder race and watched AI invasion after invasion get wiped out, possibly using the birth rate enhancing buildings.