So I had found two question based on the title one was talking about momentum operator in bound statebound state and the other was a more general. Where in the first bound state calculation they had related $\langle p \rangle \sim \langle[H,x]\rangle $ and then further proved $$\langle [H,x] \rangle = \langle n | [H,x] | n \rangle = \langle n | Hx-xH | n \rangle = E_n ( \langle n| x | n \rangle - \langle n| x | n \rangle) =0$$$$\langle [H,x] \rangle = \langle n | [H,x] | n \rangle = \langle n | Hx-xH | n \rangle = E_n ( \langle n| x | n \rangle - \langle n| x | n \rangle) =0.$$
Here I did not understand why bound state was a necessary condition since they never used any potential term or let alone expand any operators. Moreover in the general solution, they didn't get 0 but were stuck at $$ \int\left(i \hbar \frac{\partial}{\partial x} \psi^*\right) \psi d x $$ this integral in the end which did not give zero.
Could someone explain why the solutions work differently and why the first solution can't be true for any 0 potential system?
Note: Both the solution make sense and seem logical but I'm not able to understand why it's different because of the conditions.