The terms were adopted in the United States in an attempt to loosely group immigrants and their descendants that arrived in the US from Latin America. The terms were and sometimes still are used interchangeably. The categories only refer to a person’s origin and ancestral background. The terms have since evolved. In an overly simplistic way, the term Hispanic refers more to language while Latinx refers more to culture.
Latino is from the Spanish (or Portuguese) latino americano and refers to those from Latin American countries who speak romance languages like Spanish, Portuguese, or French. Hispanic is generally accepted as a narrower term that refers to people who descend from Spanish speaking countries.
As with any personal identifying factor the individual can choose to identify as both, either, or none even if they meet the “textbook definition” of either term.