The 24 star flag was used from 1822-1836.....by the UNION, most likely the time period this button was made.
If it was confederate made, WITH stars, it would have either 7,9,11 or 13 stars. Although the Missouri State Flag used 24 stars from 1861-1865, likely not relevent to this button.
My guess would be it is a Union button probably not military but perhaps civilian. The clues of 24 stars(Union) and (SIMILAR)Confederate Navy Anchor design raises doubt that it is military, too much conflict in design I think.
I am a little bit confused as to the navy confederate design(the one presumably copied on this button) as the Confederacy began around 1860. The Union was already using 33 stars by then,1860, and added one more (34 stars) in 1861. My confusion would be lightened if I knew this particular Navy Anchor design predated the Confederacy and more precisely to about 1822 to 1836. I just don't know enough about the CS button designs. Or if its civilian that also explains alot! (inaccuracy)
All this talk about Confederate designs and I think the 24 stars rule out confederacy.
I love a good mystery!