Why is Madagascar an African country but not located in Africa?

Madagascar is located near Africa but is geographically part of the continent. It lies off the southeastern coast of Africa, separated by the Mozambique Channel. Despite being near Africa, Madagascar is considered an island continent or a continental island due to its unique geological history and distinct flora and fauna.
Copyright Wanderlust World © https://www.ynyoo.com