Especially with the Intel i7 and i9 CPU models on Macbook Pros 2018, a lot of heat is generated. To prevent overheating, fans need to cool down the CPU.
There is a feature called "Turbo Boost" which enables higher cock speeds for CPU intensive workloads. This mode generates more heat when it is turned on. Unfortunately this option get automatically enabled very often for my use-cases. Fans are constantly turning at high speeds which gets loud.
Turbo Boost Switcher. This reduces the performance of the CPU by turning off "turbo boost" when the temperature and fan speed gets above a certain level.