Maury was a descendant of the Maury family, a prominent Virginia family of Huguenot ancestry that can be traced back to 15th-century France. His grandfather (the Reverend James Maury) was an inspiring teacher to a future US president, Thomas Jefferson. Maury also had Dutch-American ancestry from the "Minor" family of early Virginia.  He was born in 1806 in Spotsylvania County, Virginia, near Fredericksburg; his parents were Richard Maury and Diane Minor Maury. The family moved to Franklin, Tennessee, when he was five. He wanted to emulate the naval career of his older brother, Flag Lieutenant John Minor Maury, who, however, caught yellow fever after fighting pirates as an officer in the US Navy. As a result of John's painful death, Matthew's father, Richard, forbade him from joining the Navy. Maury strongly considered attending West Point to get a better education than the Navy could offer at that time, but instead, he obtained a naval appointment through the influence of Tennessee Representative Sam Houston, a family friend, in 1825, at the age of 19.  Maury joined the Navy as a midshipman on board the frigate Brandywine which was carrying the Marquis de La Fayette home to France, following La Fayette's famous visit to the United States. Almost immediately, Maury began to study the seas and to record methods of navigation. One of the experiences that piqued this interest was a circumnavigation of the globe on the USS Vincennes, his assigned ship and the first US warship to travel around the world.

Answer this question "How or when did he become interested in astronomy or the ocean?" by extracting the answer from the text above.
He wanted to emulate the naval career of his older brother, Flag Lieutenant John Minor Maury,