The metaphor for In[n] and Out[n] should be thought of as the inputs and outputs sequential in time, not line, linearly from the top of a notebook to the bottom. It is, one way of thinking, a potential confusion in the documentation for how In and Out are often described
?In
In[n] is a global object that is assigned to have a delayed value of the n^th input line. >>
Although n is a "line number" parameter here, it in reality is a time parameter in "ticks of a clock' where the clock ticks once each time you execute an input.
One could create another tag for cells that is unique to the cell and which behaves the way you wish. It requires uniquely tagging a cell and using that to keep track. There is an option to notebooks that can help: CreateCellID. And the parameter $PreRead may play a part. If I get the time I may put something like this together.