I think thats more a myth propagated by movies/books rather than religious scriptures. I have not read a single Hindu scripture that talks about “7 births”.
However, I can see the intent behind that myth. A soul gets only “so many” chances on earth to do good deeds (karma) and make their place in heaven. After a finite number of chances on earth (7 in case of this myth), they would go to either heaven or hell.