Knife Guy (enemy)
From the Super Mario Wiki
Most Knife Guys are encountered normally on Yoshi's path, but some appear from behind shoji-like doors. They carry ninja swords, which they point in front of them while running. When they bump into a wall or another Knife Guy, or simply encounter a platform's edge, they stop for a short time before turning the other way and continuing to scurry. Yoshi receives damage if he gets run into by a Knife Guy, although he can defeat the enemies by using any attack method.
In Outer Orbit, there is a space-themed skin of Knife Guy, along with several other Shy Guy types. This Knife Guy wears silver clothing and a space helmet, and hops out of spaceships wielding space swords resembling glow sticks. However, it acts much the same.