The reason why Buddhists can't eat garlic is because garlic is considered to be one of the 5 pungent vegetables.
The 5 pungent vegetables are believed to stimulate strong emotions such as desire and anger and makes it difficult to focus on meditation and achieve spiritual clarity.
Essentially the strong smell and taste of garlic are thought to cloud the mind and hinder spiritual practice.
In Buddhist philosophy, garlic is also categorized as a "rajasic" food, meaning that the garlic is stimulating and can lead to agitation and restlessness
The strong smell and taste of garlic are believed to disrupt concentration during meditation.
Besides garlic, onions, leeks, chives, and shallots are also usually avoided for the same reasons.
Although many Buddhist traditions discourage consuming garlic, it's important to note that not all Buddhists follow this practice and the interpretation of dietary restrictions can vary depending on individual beliefs and lineage.