This is not a problem as such, but is due to a function of energy management. So if when you open the notification bar they are automatically deleted, it is completely normal.
How to solve it?
You must go to Settings, Battery, Hibernation of the application / aggressive sleeping mode and deactivate it. On the other hand, if you just want to keep some notifications, you can add them to the list of exceptions. For this, go to Battery, Battery Optimization (touching the three vertical points in the upper right corner). And then go to All applications, just select the one you want to add to the list.