Many things can contribute for this. What’s your theme? What are the css snippets you use?
It’s obvious that you don’t use the default theme and your headings have some extra css style. For example, one of the problems may be in the margin-top value defined for h1, h2, h3 …
An example for heading h2:
.markdown-preview-view h2 {
margin-top: 20px;
}