Check that other games in your collection that uses the Z buttons are working with them. This way, we know for sure those two games you listed are problematic.
I dunno if Xenoblade and Fire Emblem Warriors have options where you can change control schemes that use Z buttons.
Is your 3DS hacked with CFW? Are the two games digitally installed on Home Menu?
The last recommendation is to backup your saves for those two games using Checkpoint or JKSM. Uninstall and reinstall the games with good CIA copies. Restore the saves and check if the buttons work then.