Gboard on Galaxy S7

Could it be that you're accidentally tapping the Back or Home button while typing?
 
My apologies. I wasn't very clear. Gboard is being randomly replaced with the Samsung keyboard. It seems to happen after updating apps. Not sure if the two events are related or not.
 
Can you Disable the Samsung Keyboard app in Settings>Apps (assuming you prefer never to use it)?