php loading different structure than source code

You’re using template tags within an echo statement that themselves echo a value. You need to use the versions that return their value.

the_permalink() should be get_permalink, the_post_thumbnail should be get_the_post_thumbnail, the_title should be the_title( '', '', false ), the_content should be get_the_content().