拜了个拜 derives from 拜拜 by treating the first 拜 as a verb and the second 拜 as the object of the first 拜 and them adopted the verb+(quantity)个+object pattern.
拜拜 is just a loan word from English bye-bye and mean the same thing.
拜了个拜 is just a novel usage of the word.