I am trying to add an image as a cover of my ebook in "edit book" mode, so I choose "Add cover" from "Tools" menu, add my image and for a moment it seems to work, however very quickly the image is replaced by an image generated from title and author metadata (it seems), which is not what I want.
Calibre has had an option to insert a cover long before it offered editing some ebook formats. That option comes with additional utilities of finding a fitting cover using some internet services. If such a cover is not selected, calibre generates its own and inserts that in the epub file.
With the relatively new editing possibilities in Calibre, the cover still comes from this explicit selection (via the metadata editor). And any hand-crafted cover page gets overwritten by the "insert cover from metadata" functionality.
That cover is actually stored along with the ebook and the metadata in the directory where the ebook is stored. You can probably just replace that there, or select the cover you want via the metadata change functionality.