There was a John Bagley in the 1810 United States Census living in Machias, Washington, Maine. Machias, Maine was the birthplace of Samuel Bagley in 1795, so, John could be Samuel's father.
John Bagley is also in the 1820 US Census for Machias, Washington, Maine.
It would be better to have some evidence that the two are related, before jumping to conclusions.