A person cannot direct dial a hotel room from outside the hotel. All incoming hotel phone calls go through the hotel operator or receptionist first. Call the hotel's direct dial number, and give the operator the last name of the person and the room number. She will connect the call.
To call a hotel room from inside the hotel, a caller must follow the dialing instructions, which usually means dialing "9" before the room number. Hotels use a telephone switchboard. The original switchboard, invented by Almon Strowger in 1888, used to physically connect wires in order to connect the telephone calls. In 1919, the Bell System developed automatic switching, but the first manual switchboards continued to be used through the last half of the 20th century in hotels and offices.
While there are now auto-attendant switchboards and virtual switchboards that replace the need for a human operator, hotels and other businesses still rely heavily on the personal touch of having an actual person answer the phone call. There are many reasons hotels and businesses do not allow calls to go through directly. The person receiving a call may have a preference to take some calls personally while asking for messages from other callers. A human operator can make judgment calls that most computers cannot.