Issue with TRIM command leaving incomplete line segments

When using the TRIM command ("Specify segment to remove"), clicking an entity does not trim it completely at the intersection, leaving unexpected line fragments. Sometimes it works fine, but other times it leaves these remaining segments.

What could be causing this, and how can I resolve it?

Any advice would be greatly appreciated.