The connection between militarism and imperialism is that militarism often supports and enables imperialism. Militarism is the belief in the importance and necessity of a strong military to protect and promote national interests. Imperialism is the policy of extending a country's power and influence through diplomacy or military force to acquire and control territories or colonies.
Militarism often supports imperialism by providing the military force necessary to conquer and control territories or colonies. It also promotes the idea that it is necessary and justified to use military force to acquire and maintain colonies for the benefit of the nation. In turn, imperialism often fuels militarism by providing justification for the need for a strong military to protect and maintain the colonies.
In short, militarism and imperialism are closely connected and often support and reinforce each other.