First, the trim plane is not the best tool for finish passes on the stringer to make it flush with the foam. You want to use a spokeshave for that.
When using the trim plane drag it along the stringer on a 45 degree angle to help keep it flat and not rock sideways which can gauge the foam. Also go along the grain of the wood. You'll know when you're going against the grain because the trim plane will dig in deep an get stuck.
You can also file a radius on the edges of the trim plane blade to keep them from hitting the foam.