DRS is given to you when you're within 1s of the car in front. It can be a teammate's car, a direct opponent or even a trail car.
You need to pay close attention to those trail cars that aren't retiring and might be in your way in the last couple of laps. They are race changers. Specially when defending a position or preventing being the first car of a DRS train on the last lap ?
I’ve experienced this before. I was about to lap a backmarker down a drs straight, and the backmarker got DRS. I did notice that my car was very close behind his, so the server may have registered it as that the backmarker was behind my car.