Keyboard keeps defaulting to wrong layout

I had a similar issue and solved it by doing two things.

1. Dconf Editor

Install dconf-tools and open it. Under desktop/ibus/general find engines order and change it to your preference.

ibus-setup

open a terminal and type ibus-setup Under the advanced tab tick the use system keyboard layout option.