On Youtube it shows chess engines as humanoid robots (here, for instance). Is this true, and if so do they play chess over the board according to their software? That would explain why they don't always play the best move according to their algorithm.
No, chess engines are not humanoid robots. That is just something that the YouTube channel uses to represent the engine so that the videos are more approachable for the intended audience. Chess engines are simply software that run on computers. People may make a robot or animated personality to go with the engine, but that would be entirely separate from the engine itself, and it would not change what the engine does.
Strictly speaking, a chess engine is just a piece of software that defines some criteria for differentiating between good and bad positions. When given a position to analyze, it will yield the best move according to this criteria. It takes time and resources to find this best move, so the same engine analyzing the same position with different amount of time or computer resources may yield different results. This would be especially noticeable when comparing to the performance of an engine that is playing a match, where time is limited, to the same engine analyzing a position after a match, where time is unlimited.