If there is a war and an army general(COAS) is also the president of your country, he automatically becomes a field marshal.
You may think that why was Musharraf not a field marshal, well, that's because Kargill was not a declared war but a conflict.