Lots of East Asian martial arts heavily emphasize spiritual beliefs. Some are mostly or entirely spiritual practices at this point, like Tai Chi and Baguazhang. How did martial arts evolve from "ways to fight people" into schools of philosophy?
The Chinese martial arts, as mentioned in the question, generally do not emphasize spiritual beliefs.
Scholars have accepted that Taijiquan was created in the mid 17th century by Chen Wangting (1580-1660) who combined seven northern ancestral Chinese self-defense routines, Buddhist/Daoist cultivation methods, and a tuishou (Push Hands) curriculum. This martial art was passed down in the Chen Family for many generations, and they are known to be reluctant about teaching their craft to outsiders - members outside of their family.
About five generations later, Chen Changxing (1771-1853) is accredited to have synthesized the seven forms into two very large forms known as Yi Lu and Er Lu which are still practiced till this day.
Yang Luchan became one of the first outsiders to learn from the Chen Family - mainly from Chen Changxing. He spent 18 years to learn it. He is considered to be the founder of Yang Style Taijiquan, passed down in the Yang family. He has removed many series of movements such as jumps, leaps, explosion of strength, and foot stamping. This deletion of movements is clearly shown by the fact that almost the entirety of Er Lu (the second form of Chen Style) has not been passed down in the Yang family. Yang Luchan's sons and grandsons have made further alterations to their craft, leading to different branches.
Because Yang Style was the first to be shown to the public, they have become the most popular style of Taijiquan in modern era. Whenever you hear about the stereotypes of the elders who practice Tai Chi for health and spirituality, they are likely practicing Yang Style - mainly under the popular lineage of Yang Chengfu, the grandson of founder. Meanwhile, the lineage of Yang Ban-hou, a man known for his temper and rigorous training, is where Wu Style Taijiquan was derived from.
There are different styles to Taijiquan, so it is important to note that in today's times, most people's conception of "Tai Chi" stems from Yang Style Taijiquan. While historically, Buddhist and Daoist cultivation methods were borrowed and integerated into the art, Taijiquan has never traditionally taught the philosophies of buddhisim or daoism.
The term, Taiji, refers to the dynamic interplay between Yin and Yang, as it does well to describes the martial art system. However, Taiji Praying Mantis style also uses the word "Taiji" in its name, yet they are not related to Taijiquan.
The association of spirituality with Taijiquan stems mainly from the recent decades of marketing of grouping Tai Chi with other categories such as Yoga.
It is also worth clarifying that the word Chi/Qi (氣) is a completely different character than Tai Chi/Ji (極). While Taijiquan does have elements of Qi Gong, it by no means has the word "Qi" or "Chi" built into its name as many non-Chinese speakers tend to believe. But that misnomer also contributes to the false perception that Taijiquan is traditionally a spiritual practice.
Traditionally, Taijiquan, deep in the family lineages, is often known for its standup grappling and striking techniques - including punching, kicking, elbowing, kneeing, piercing, chopping, clawing, smashing, shocking, shoulder striking, deflecting, cutting, wrapping, hooking, scooping, pressing, head control, throwing, joint locking/breaking/manipulation (Qinna), sweeping, etc…
Like many martial arts, Taijiquan also includes cheap shots such as targeting the throat, eyes, groin, solar plexus, etc…
Taijiquan is a self-defense practice, but the traditional ways of practice are extremely rare.
Baguazhang is also a Northern Chinese martial art, just like Taijiquan. Its founder is often accredited to Dong Haichuan who was known to cater his teachings based on the physical attributes and prior martial art experience of his students. Due to this approach to teaching, Bagauzhang have several branches such as Yin Style, Cheng Style, Laing Style, Gao Style, and Jiang Style.
The question of spirituality has less to do with the history of these arts and more to do with the more recent times of how the public come to perceive these arts through the influence of media.
While you will find many exotic and possibly vague poetries and songs written about these arts in ancient texts, it should be noted that most people in ancient China were illiterate. These arts were traditionally passed down orally, physically, and through hands-on approach. So, the ancient texts should be taken with a grain of salt as we should be mindful that they likely did not have the literacy skills to fluently convey these complicated martial art systems in written words.