The story of Jaya-Vijaya the doorkeepers of Vaikuntha the abode of Lord Vishnu can be found in Srimad Bhagavata Purana Skanda 3 -Chapter 15. Here in this story we find the interesting account of how once the mighty sanat kumaras the mind born sons of Lord Brahma once visited Vaikuntha and been stopped by doorkeepers. The doorkeepers Jaya And Vijaya got cursed by Sanat Kumaras and the reason of their welfare .
If they teach them about their deeds then what Sanat Kumar teach them?
What Sanat Kumaras taught to Jaya-and Vijaya is that they are the Parshadas (attendants) of Lord Vishnu and are living in highest abode "Vaikuntha". And after great devotional service to the lord those people who attain Vaikuntha loka do not see any difference in between them and Lord Vishnu and they also behave or posses similar qualities like impartiality as of lord.
Since this entire universe is contained inside belly of lord Vishnu that is why people living in Vaikuntha do not see any difference in between them and in Shree Hari. Sanat Kumaras wondered that How come this indifference came in the minds of thesd two inspite of this?
पश्यन्ति यत्र युवयो: सुरलिङ्गिनो: किं |
व्युत्पादितं ह्युदरभेदि
भयं यतोऽस्य ॥ 33 ॥
तद्वाममुष्य परमस्य विकुण्ठभर्तु: | कर्तुं
प्रकृष्टमिह धीमहि मन्दधीभ्याम् । ॥ 34 ॥
Sanat Kumaras also said that although your outward appearance is like gods but you are really Daityas. i.e. they still possess some doubts in their minds about oneness of lord and themselves. And even though they are subordinates of lord they are really of weak mind.
Why Dwarapalakas did stop Sanat Kumaras ?
According to narration Of Bhagavata Purana Sanat Kumaras were looking like 5 years children. They were without clothes and were shining very bright from their Yoga Tapas. Seeing that Sanat Kumaras passed the gated easily they with disrespect stopped them . The Dwarpalas did not considered their luster , they treated this tejas of sanat kumaras disrespectfully and did considered it as very nominal , as they were not aware of powers of Sanat Kumaras
why they thought Dawarpalas should not stop them since Dawarpalas were just doing their job?
They did not thought that Dwarpalas should not stop them simply because they didn't needed permission of jaya and Vijaya. They were having so much power that they had passed previous 6 doors uninterrupted. And were capable of bypass Dwarpalas also. But since they were in Vaikuntha they did not behaved like arrougents and let Jaya and Vijaya do their job. But since they wanted to teach Jaya and Vijaya a lesson they stopped at them.
they thought stopping them was against dharma
No they did not thought that stopping them is against dharma. The Sanat Kumaras were already liberated souls so they were beyond Dharma-Adharma that time.
Here is another storyline from translation of
Swami Prabhupada - Verse 26-37.