I found the answer on wikipedia link about panch kedar
The Pandavas defeated and killed their cousins — the Kauravas in the
epic Kurukshetra war. They wished to atone for the sins of committing
fratricide (gotra hatya) and Brāhmanahatya (killing of Brahmins — the
priest class) during the war. Thus, they handed over the reigns of
their kingdom to their kin and left in search of the god Shiva and to
seek his blessings. First, they went to the holy city of Varanasi
(Kashi), believed to Shiva's favourite city and famous for its Shiva
temple. But, Shiva wanted to avoid them as he was deeply incensed by
the death and dishonesty at the Kurukshetra war and was, therefore,
insensitive to Pandavas' prayers. Therefore, he assumed the form of a
bull (Nandi) and hid in the Garhwal region.
Not finding Shiva in Varanasi, the Pandavas went to Garhwal Himalayas.
Bhima, the second of the five Pandava brothers, then standing astride
two mountains started to look for Shiva. He saw a bull grazing near
Guptakashi (“hidden Kashi” — the name derived from the hiding act of
Shiva). Bhima immediately recognized the bull to be Shiva. Bhima
caught hold of the bull by its tail and hind legs. But the bull-formed
Shiva disappeared into the ground to later reappear in parts, with the
hump raising in Kedarnath, the arms appearing in Tunganath, the nabhi
(navel) and stomach surfacing in Madhyamaheshwar, the face showing up
at Rudranath and the hair and the head appearing in Kalpeshwar. The
Pandavas pleased with this reappearance in five different forms, built
temples at the five places for venerating and worshipping Shiva. The
Pandavas were thus freed from their sins. It is also believed that the
fore portions of Shiva appeared at Pashupatinath, Kathmandu — the
capital of Nepal.
A variant of the tale credits Bhima of not only catching the bull, but
also stopping it from disappearing. Consequently, the bull was torn
asunder into five parts and appeared at five locations in the Kedar
Khand of Garhwal region of the Himalayas.[7] After building the Panch
Kedar temples, the Pandavas mediated at Kedarnath for salvation,
performed yagna (fire sacrifice) and then through the heavenly path
called the Mahapanth (also called Swargarohini), attained heaven or
salvation.
After completing the pilgrimage of Lord Shiva's darshan at the Panch
Kedar temples, it is an unwritten religious rite to visit Lord Vishnu
at the Badrinath Temple, as a final affirmatory proof by the devotee
that he has sought blessings of Lord Shiva.
further reading can be found here : details about panch kedar
a little different version I found on other site says,
When the Pandavs went to the
Himalayas, Shiv avoided them because they had killed so many people in
the war. To avoid them He ran in the form of a Bull, and Bhim chased
him. On being followed, the colossal Bull dived into the ground to
resurface at other places. He left his hump at Kedarnath. But when he
resurfaced, it seems that he had assumed human form and emerged at
different areas in these mountains. His Face resurfaced at Rudranath.
His Arms resurfaced at Tungnath. His Naval (torso, I guess) emerged at
Madha Maheshwar. His Hair emerged at Kalpeshwar.
further reading here