A bit of both. China really wants to get hold of Taiwan, and have a navy capable of dominating its surrounding maritime landscape. Right now, an attempted invasion of Taiwan would lead to a lot of sunken ships, so they need better naval capabilities, and expansion of the navy is therefore needed to fulfil military ambitions.
But the bigger issue right now, one which the media doesn’t pick up, is that China is currently facing some serious domestic issues. The most significant, perhaps, is that it looks like the country’s population is in decline (the 2020 census may have overstated China’s population by 130m), which may accelerate due to sex imbalances. Meanwhile, the flooding of 2021 severely degraded much of the country’s arable land. If you are the ruler of a country of a billion people, dependent on imports of food and fuel, you may well feel vulnerable, particularly if most of these imports come in by sea through the Straits of Malacca. The Chinese leadership is acutely aware of national vulnerabilities, and are attempting to counter this through an aggressive projection of power.
The Chinese government is perturbed by the current conflict in the Ukraine. They have been building up their military for years, to both bully other countries (defensive) and to conquer Taiwan (offensive), but are now seeing that it would not be an easy war, and they would likely see unified international opposition to any conflict. There is, I suspect, a lot of debate behind closed doors in Beijing as to where China should go in the current circumstances, a fact which probably explains a lot about the somewhat lukewarm Chinese support for the current conflict.