Need to output comment_form() function inside a foreach loop

This is because you’re collecting the HTML in a variable before you output, but comment_form does not return HTML, it immediatley renders.

So, eliminate the $achievement_post variable, and output directly with echo instead, and things will work more as you expect