It changes it's form based on attack. Direct contact moves (moves that it uses to damage not through status issues and things related to status issues) will revert it to Blade Form, and moves that do not do direct damage (or none at all) will revert it to Shield Form.
E.g Aegislash uses Shadow Sneak, it will become Blade Form, next turn, it uses King's Shield, it becomes Shield Form. It changes forms before it uses the selected move.
Hope I helped