Keep in mind that around this time Freemasonry was everywhere. Almost every man in the US had some sort of connection with Freemasonry or one of its offshoots such as Odd Fellows, Foresters and so on. It was simply accepted as fact that the Freemasons possessed deep secrets and the keys to powers bordering on the supernatural. They were (and still are) inordinately enamored of anything Egyptian. So it was an obvious move by JS to incorporate Masonic elements into Mormonism.