It was Pakistan who attacked independent Kashmir state and Indian forces entered only after legally merger of Kashmir with India (see instrument of accession)
1)
a) International law clearly states that every treaty entered into by a member of the United Nations must be registered with the Secretariat of the United Nations.
"The Instrument of Accession" was neither presented to the United Nations nor to Pakistan. Hence India cannot invoke the treaty before any organ of the United Nations.
b) The legality of the Instrument of Accession may also be questioned on grounds that it was obtained under coercion. The International Court of Justice has stated that there
"can be little doubt, as is implied in the Charter of the United Nations and recognized in Article 52 of the Vienna Convention on the Law of Treaties, that under contemporary international law an agreement concluded under the threat or use of force is void."..... India’s military intervention in Kashmir was provisional upon the Maharaja’s signing of the Instrument of Accession. More importantly, however, the evidence suggests that Indian troops were pouring into Srinigar even before the Maharaja had signed the treaty. This fact would suggest that the treaty was signed under duress.
c) The Maharaja had no authority to sign the treaty, hence the Instrument of Accession can be considered without legal standing . The situation on the ground demonstrates that the Maharaja was hardly in control of the state of Jammu and Kashmir. Hari Singh was in flight from the state capital, Srinigar. And it is highly doubtful that the Maharaja could claim that his government had a reasonable chance of staying in power .....
Thus, an analysis of the circumstances surrounding the signing of the Instrument of Accession shows that the accession of Kashmir to India was neither complete nor legal, as Delhi has vociferously contended for over sixty years.
Moreover, further shedding doubt on the treaty`s validity, in 1995 Indian authorities claimed that the original copy of the treaty (letter of accession) was either stolen or lost !!!
2)
Accession of Kashmir is different from accession of any other Indian Princely State as the accession has been placed before the UN Security Council for arranging a ratification or otherwise by the people of the State under the auspices of the United Nations.
Therefore, the arrangement caused through the accession of 26 October 1947 has been taken over by the interests of 195 countries of the UN (including Pakistan as a member nation of UN and as a party). Pakistan as a party to the dispute administers two administrations of the State on its side of cease fire line.