Formulating hypothesis posteriorly for Binomial Testing A common example of teaching binomial testing is viewing the results of some coin flips, seeing a total number of heads greater than the expected value, then formulating the null hypothesis that the probability of flipping heads is not biased and calculating the p-value from the binomial distribution. This null hypothesis is formulated based on viewing the data and seeing the abnormally high number of heads, and then the testing and subsequent p-value is obtained from the same data. Why is this ok to do when generally you are not supposed to use the same data to both generate and test hypothesis?
 A: 
Why is this ok to do when generally you are not supposed to use the
same data to both generate and test hypothesis?

You are not doing that in your example. The hypothesis that you would expect evenly distributed heads and tails totals is based on prior experience and human logic.
Anyways, the data at hand, by which the hypothesis is created, is a certain distribution of heads, while your test would not use the same data (=this distribution). Instead you would simulate a new distribution based on a fixed probability of tossing heads.
No matter how I look at it, I can't see a problem.
A: It is always dangerous to attempt to "test" a hypothesis with the same data that initially suggested the hypothesis (or that made that particular hypothesis interesting). That's because there is going to be a greatly elevated chance that the test will provide a false positive. After all, if the data look like they support a particular hypothesis there is a good chance that a statistical test will also support that hypothesis, and the data will always appear to support some hypotheses more than others. Hypothesis testing should be specified in advance of obtaining or seeing the data.
There is an important alternative approach if you want to characterise the system rather than to "test" a hypothesis concerning the system: you might plot the likelihood function to see which hypotheses are relatively well supported by the data.
You might like to read this to put hypothesis testing and p-values into context: https://link.springer.com/chapter/10.1007/164_2019_286
