The issues would have never happened if they hadn't colonized India to begin with. It's more nuanced (and interesting) for the exit.
Pakistan wanted to not be a part of India with Muhammad Ali Jinnah pushing the two nations theory. The reverse was less true but the Indian leadership under Nehru reluctantly agreed to the split. That's despite the British best effort to meditate because in places like Kashmir and Bangladesh the separation would be hard and economicly ruinous for the area. Not to mention displacing millions of peoples
Viceroy Mountbatten rushed the exit out of india. And the Radcliffe line (the hastly drawn border between the two sides) was a complete mess but also a result of being rushed in 5 weeks. Both this led to a horrible refugee crisis/mutual genocide. But a longer British stay would have been difficult with all sides pushing for their exit and fear of mutiny in the army whith the recent Indian navy mutiny of 1946
All that to say stuff if complicated. But border ends up shity like you said. We could have a whole debate about how much this messy independence is to blame for the multiple conflict between india and Pakistan and the Bangladesh genocide