This question already has an answer here:
'Return' keyword returns only one element from a loop?
The first solution basically says "return all (left, right) pairs that match the following criteria"
The second solution says "search for a pair, that matches the following criteria. As soon as one is found, return it". Therefore only one is returned. I haven't tested this, but I it should be the first one encountered, not the last one.
To fix it: instead of returning a pair which is found in the second solution, add it to an array of solutions, and return that array after the for loop.