Is the Buddha capable of making mistakes? There is a sutta where the Buddha teaches some disciples about loathsomeness of the body. He then goes on a retreat into the forest. On his return, he finds the disciples have committed suicide as they have grasped the teachings incorrectly. The Buddha than proceeded to teach Anapana Sati as it is much safer. Does this prove that even the Buddha was capable of making mistakes? In hindsight, should he have used the ability of omniscience to anticipate the result of his instructions. Or, was this event unavoidable fruition of the disciples' past Kamma.
You have misunderstood the sutta SN 54.9.

The Buddha taught the technique of loathsomeness of the body, which is to be used to remove feelings of sexual lust and attachment to the physical form. This technique is useful to be practised by a monk or practitioner who is overwhelmed by sexual lust. However, too much of this practice, especially when it is unnecessary, may lead to depression and suicidal tendencies.

To counteract depression and suicidal tendencies, the Buddha prescribed mindfulness of breathing, which can generate rapture and joy.

So, as you can see, every technique has a different purpose. Any one single technique does not fit everyone at all times. Sometimes, you have to change your technique depending on the circumstances.

For example, a person who is momentarily overcome by one of the five hindrances would have to try some technique to overcome that particular hindrance.

Hence, the Buddha did not make a mistake in this case. He merely prescribed different techniques for different conditions. Please also see this answer.

The Buddha will not make mistakes when it comes to the teachings and practice of Buddhism.

Although the Buddha was known to have some psychic powers, he was not completely omniscient (i.e. knowing all things in the past, present and future), in the way people consider a Supreme God to be. Buddhist enlightenment is about freedom from suffering. It's not about becoming God-like.