Walls are defensive structures. Hadrian built one to keep the Scots out
Yep. Once the Romans decided not to conquer the north, they built the wall to keep Scottish raiders out, and cut the Celtic tribes in their territory off from the unconquered tribes in the north.
The problem with the Celts is they were almost never unified, and hated the neighbor tribes more than the outsiders. That allowed outsiders, the Romans, and later the Anglo-Saxons to divide and conquer.