Origin of the term
The expression comes from the HTTP specifications. RFC 1945, from May 1996, defines the user agent as "the client which initiates a request" and lists browsers, editors, spiders (web-traversing robots) and other end-user tools. RFC 9110 adds that browsers are only a small share: mobile apps, household appliances and firmware update scripts are user agents too.
Almost every browser starts its string with "Mozilla/5.0". MDN puts this down to "historical reasons". The HTML Standard keeps the same legacy in JavaScript: navigator.appCodeName always returns "Mozilla" and navigator.appName returns "Netscape", so that existing websites keep working. Engine names went the same way. According to MDN, many browsers added the names of other engines so that websites would not shut them out by name. That is why Chrome writes "KHTML, like Gecko" and "Safari" although it is neither. RFC 9110 discourages the practice because it defeats the purpose of the field.
