It's a cold war tale. Nigerian Prime Minister Abubakar Tarawa Balewa 1960-1966 was pro-western. When he was overthrown in a military coup and murdered January 15, 1966, it sparked a counter coup, and the Nigerian Civil War (July 6, 1967 – January 15, 1970). During the Civil War the Soviets were a major arms supplier to the government, beginning the relationship which would turn into political support in the '70s.
In the 1970s Nigeria's relationship with the west began to lapse. During this same time Nigeria found itself on the same side of several issues as the Soviet Union. Nigeria was very critical of the white regimes in southern Africa, South African and Rhodesia. The Soviet Union was supporting nationalist movements in both countries and this put them on the same side of these issues. Nigeria sided with the Soviet Union throughout the '70s on such issues as action against apartheid, recognition of the MPLA in Angola, and immediate independence for Namibia.
All this interaction between Nigeria and the Soviet Union made the west pretty concerned that Nigeria was becoming a Soviet satellite state. The Soviet Invasion of Afghanistan was a reordering episode. Nigeria became a vocal critic of the Soviet invasion. Distance was placed between Nigeria and the Soviet Union and a rapprochement with the west ensued.
Sources: