Your confusion is due to the misunderstanding that India and Australia have a similar level of relationship with the United States of America. They do not.
The Indian-American alliance can be summed up as a recent needs-based alliance which is still not well-defined. Whereas the Australian-American alliance is built on shared racial and cultural heritage, and has spanned more than 5+ decades now.
Australia's alliance with the US has its root in the post-WW 2 'Atlantic Charter', which deepened during the cold war, and is reflected in the later "Five Eyes Alliance", where the Anglosphere even share intelligence with each other. Such a deep level of relationship often intertwines a country's military and foreign policy with each other, and leaves less room for independent actions. Thus, Australia's military and foreign policy will necessarily be influenced by the alliance's own concerns. So if the alliance, lead by the US, believes China is an adversary, Australia also has to accept that or leave the alliance.
That is why Australia has less flexibility in its foreign policy, on some issues like dealing with China.
India and the US, on the other hand, do not have a similar kind of relationship. In fact, for the most part, during the cold war, India did not see eye to eye with the Americans about the Russians, and were sometimes even adversaries. On China though, India does agree with the American perspective that China does pose a threat to India and other developing nation. And it is thus more willing to engage with the US.
Nevertheless, it is unwilling to be a part of any permanent military alliance because it recognizes that it will severely curtail its military and foreign policy. (This fear has its roots in India's colonial history, and its own understanding of how the superpower use developing countries for their own political purposes.)
This is evident in India's foreign policy that was crafted by India's first Prime Minister, Jawaharlal Nehru, which is popularly known as the "non-alignment" policy. It was initially created to counter the persistent demands of the super powers to join the cold-war, by forming a military alliance with one of them. This policy has been the bedrock of India's foreign policy, since its independence, because Nehru emphasised that India could create space for independent thinking and actions, however restricted, in all its international relationships, if India was pragmatic about its own position in the world order:
If we have to make our own decisions, we have to rely on our own judgement and analysis of the situation, and to keep in view our basic objectives and the foreign policy we have been pursuing thus far.
Some words are used loosely, and among these, is “neutrality”. Neutrality in peacetime has no particular meaning. It is only in war that a country can be neutral. But even in so-called peacetime, ever since the last World War ended, we have lived in an atmosphere of war and expectation of war, and hence people talk of this or that country being neutral in the cold war.
In reality, all that this means is that we have not given up the right to decide for ourselves as to what we should do and what we should not do in any particular set of circumstances. To give up that right to decide means to give up both our independence of judgement and independence of action. In other words, it means to give up our basic independence and become a satellite of some other country tied down to a policy which we may or may not like.
India has, within the inevitable limitations imposed by events, tried to follow her own independent policy in foreign, as in other affairs. No country can be hundred per cent independent in such matters because every act or policy flows from other acts done before and other things happening in the world.
But within those limitations, one can be more or less independent. We have preferred to be more independent. That was not only an idealistic approach but, I think, an eminently practical way of dealing with current problems.
To sum up, Australia feels the needs of being in an alliance with the US to preserve its economic prosperity and its military security, vis China. This has an influence on its foreign and military policy. Where as India does not believe a military alliance against China is in its best interest, and thus can act more freely than Australia.
- Five Eyes
- The concept of non-alignment forged by Nehru has found renewed interest in the global south
- Nehru's Word: A parliament session on foreign policy