The used text comparison and merge mode is not good for the type of text comparison you wanted to do with merging differences from one HTML file to the other HTML file.
It looks like you are using toolbar/menu mode and so I describe the cause of the unexpected merge with this user interface mode. I have installed only English UltraCompare and so describe the cause with the English instead of the German terms.
First, you have enabled in menu View the option Relational Lines Mode which is the eight menu item from bottom of menu View. It would be better to toggle off this option if merging differences should be done also and not just comparing the two files and the files are very similar. All the rectangles around the different blocks and the diagonal lines between the different blocks disappear on turning off Relational Lines Mode.
Second, you have enabled in menu Merge the option Line Mode Merge which is the first menu item at top of menu Merge. That is the main cause of the unexpected line merge.
It can be read in help of UltraEdit how the line mode merge differs from default block mode merge. In line mode merge the user has to select one or more lines in both panes before using one of the merge commands. This gives the user the freedom to merge any line(s) anywhere from left to anywhere to right and vice versa without or with overwriting one or more lines in destination pane.
In your use case there was no line selected at all in any pane. For that reason UltraCompare merged the active line from second pane to active line in first pane with overwriting active line in first pane. It can be seen that the caret in left pane was at end of line 265. The caret in right pane was most likely at top of the file at beginning of line 1. So UltraCompare merged line 1 in second pane over line 265 in first pane on executing the command Merge Second To First with enabled Line Mode Merge.
I use myself never the line mode merge feature. When I want to merge one or more individual lines from right to left or from left to right, I select the lines which I want to copy to other file, press Ctrl+C to copy them to clipboard, set caret in other pane at the position where the copied lines should be insert without or with making a selection for replacing the selection, and press Ctrl+V to insert the lines with overwriting selected lines on having lines selected at all. So I use mainly the default block mode merge which means option Line Mode Merge is enabled never by me.
Best regards from an UC/UE/UES for Windows user from Austria