This can occur when there are multiple instances of the CF CLI running at the same time or when a script is being executed in two different spaces simultaneously.
The CF CLI maintains only one session per user. If one script targets a specific org and space, and before it completes another script by the same user targets a different org and/or space, it will impact the first script. From that point onward, the CF CLI commands executed by the first script will target the org and space of the second script, and if as in this case, is executing a command for a specific app, it won't be found.
Please check the org and space where the app is not being found. You can insert a 'cf target' command as a debugging step just before the 'cf app --guid' command to verify which org/space the CF CLI is currently targeting.