Mantras as used in Hinduism and Buddhism are sacred sounds, utterances, words, short prayers, or sentences in the Sanskrit language, of which it’s believed that they have religious, transformational, protective, healing, magical, and/or spiritual powers.
Some mantras have a specific literal meaning, but many don’t have any (semantic) meaning at all. Mantras may be chanted, spoken out loud, or repeated mentally, which is also called Japa Yoga.
Although the use of mantras is usually associated with Hinduism and Buddhism, rather similar practices of repeatedly uttering sacred words or phrases can be found in Taoism, Christianity, and Shamanism, among other spiritual traditions.
The types of mantras used and their particular functions and applications depend very much on the spiritual lineage and their aim, but practically they are often used in spiritual initiation rituals, as mental talismans, affirmations, or as devotional utterances to invoke wisdom, protection, or healing.
In Advaita Vedanta, mantras may be used to initiate spiritual aspirants (which is typically done by the Guru) giving them their sacred and secret phrase to remember and ponder over the teachings and Guru.
Additionally, in Advaita Vedanta, the Mahavakyas i.e. the Great Upanishadic Contemplations are also used as mantras. The Mahavakyas, however, have an explicit meaning i.e. wisdom contained in them which the aspirant needs to discern and realize in their lives as an actual living truth.
Mind also that Advaita is a Jnana Yoga tradition (the Path of Knowledge), but traditionally many Advaita practitioners would also engage in Bhakti Yoga (Yoga of Devotion) in which mantras are used as a means to cultivate inner devotion and a deeper connection to the Divine.