I'm a Computer Science student currently studying Bayesian Statistics and I'm doing some simple simulations in R to become more familiar with the concepts.
Recently, I tried generating samples of data $X$ where $X|p\sim Be(p)$ and $p\sim \text{Unif}(0.25,0.4)$. This was done by generating random samples of $p$ and then using each random sample of $p$ to generate 1 sample of $X$.
I then used a uniform prior on $[0,1]$ and tried to recover the distribution of $p$ using Bayesian methods. But I ended up with a posterior distribution that has the bell curve-like shape centred at around $0.31$ instead of the true distribution of $p$ which should be $\text{Unif}(0.25,0.4)$.
From what I was learning, it seems like Bayesian methods can have two interpretations – 1) where we use the prior to model the belief about the parameters but the parameters can be fixed and 2) where the parameters themselves follow some sort of a distribution. So why doesn't this work? Does this make sense theoretically? And does it have a link to hierarchical modeling as well?