Usually when this occurs ,its a problem with the TCM..Transmission control module..
It may be a fault with the TCM itself..
The vehicle is designed to go in whats called "limp in" mode..meaning when a fault occurs,the transmission will default into 2nd gear,it will drive,but not like its supposed to,so you can make it into a repair facility.
You dont know history of the vehicle i take it since you just bought it...maybe it had some recent work done to the transmission,this certainly would require a reprogramming of the TCM...
I would take it in for service right away,this is definitely not right.
Let me know how you make out