It's a fairly natural mistake. You are using the pin as an 'input' so you set the pinMode() to INPUT. It works 100% of the time on an UNO and 99.99% of the time on a Nano. It's only that one case where you are setting A7 as an INPUT after setting Pin 10 as an OUTPUT that the problem manifests itself.
If I had not done a deep dive into the firmware the first (and only previous) time someone reported such A problem I never would have guessed that the firmware wouldn't check for out-of-range values.