Why do my knees hurt when I use a trainer?
Thanks to @R.Chung I was able to do some research and figure out what my problem might be.

This article, Climbing vs time-trialling: same effort, different power output, explains in great detail the differences in inertial load.

To sum it up in relation to my problem:

When on the road where the elevation changes often I use slow twitch muscles and exert force longer during the pedal stroke and occasionally fast twitch muscles for stretches of flat ground.

On the trainer I use fast twitch muscles a lot more, because I only exert force for a very short period of time on only a small portion of my pedal stroke.

The muscles in my legs/knees are not used to having to fire that rapidly for such a sustained and extended period of time which is what I believe is causing me pain.