Guru Nanaks first teaching was that there is no Hindu or Muslim, and hence no religion. Truth is One, it cannot be confined to a religion, it is All Pervading, the powerhouse of the Universe and the knower of hearts.
The Gurus knew this, we all know the Truth really deep down, the answers all lie within us, where else did Guru ji get them from if not from God within.
The Guru taught us to treat others with respect and to respect the freedom of humans to practice what belief they choose.
But they glorified Truth, hence when they saw someone adding rubbish to it, they called it out. When they did many listened to their own hearts(God) and knew it was the Truth.