Of course you don't need to install the 6.31 update before. Installing 6.40 is just fine and will update your A5 templates and techdemo to the latest version.

Your error messages indicate that you've tampered with the A5 templates, f.i. copied old template files from the template folder into one of your game folders. This, of course, can not be fixed by an update.