When this happens on a bike it means the rear hub has a problem - bearings need to be serviced is the most likely solution.
Can be caused by a number of things, including regular wear and tear, but basically you need to take apart the hub and see what’s ‘wrong’
On a trainer I assume the same would be the cause - something is out of whack with the free hub bearings causing the momentum of the flywheel to transfer directly to the cassette, causing this forward spinning motion