When Congressman Thomas Hamer filed Grant's application to West Point, he thought Grant's first name was Ulysses and assumed the middle name would be Simpson, Grant's mother's maiden name. Grant had already been using the name Ulysses Hiram Grant, supposedly to avoid the H.U.G. monogram. Here's some references:
Ulysses spent his 16th year at a boarding school in Maysville, KY. By the time he returned home, his father had decided to send him to school at the U.S. Military Academy at West Point, NY., and had secured an appointment there with the help of a political acquaintance. Ulysses had no interest whatsoever in a military life and had a great fear of flunking out. When he arrived at West Point, he was 17 years old, stood 5'1', and weighed 120 pounds. His name was changed forever when he enrolled. He tried to reverse his names and enroll as Ulysses Hiram Grant, but the appointment had already been made erroneously in the name of Ulysses S. Grant because the congressman who had appointed him thought his middle name was his mother's maiden name. Unable to correct the error, Grant took the new name as his own.
https://www.history.com/topics/us-presidents/ulysses-s-grant-1
Ulysses arrived at West Point and discovered that the congressman who appointed him, in doubt about his name, had used his middle name first and had used his mother's maiden name (Simpson) for a middle name. Officers insisted that Ulysses S. Grant had been appointed to West Point, Ulysses Hiram Grant had not. In time, Ulysses accepted U. S. Grant as his true name, insisting that his middle initial stood for 'nothing.' His family and Ohio friends continued to call him Ulysses; the other cadets nicknamed him 'Uncle Sam' for his initials, soon shortened it to 'Sam.'
https://en.wikipedia.org/wiki/Ulysses_S._Grant