At some earlier point during the same shell session, you have used cmake and that executable was found in /usr/bin.
You then installed another cmake executable in /usr/local/bin.
The bash shell caches the first location that it finds for any external command that you use, which means it doesn't have to do an expensive search for the executable the next time you use the same command. The downside of this is that it won't bother to look again when you, later, install another executable by the same name, even if it's done in a directory that occurs earlier in $PATH than the original location.
The solution to this issue is to empty the cached locations of executables that bash keeps. This is done with hash -r (rehash in the zsh shell). To only forget the location of the cmake executable, use hash -d cmake (unhash cmake in the zsh shell).
An earlier version of this question additionally wondered why the two commands type cmake and which cmake gave different results, where which cmake appeared to give the expected result (/usr/local/bin/cmake) while type cmake appeared to give the wrong result (/usr/bin/cmake).
The answer to that is that type is a built-in command in bash that will use the same cached locations of commands that the shell uses, and that which is not a built-in command and will therefore not be able to use those cached locations of executables.
In this case, which gave the expected result because it did a search for cmake in your $PATH, but it was in fact the wrong result, since running cmake on the command line would in fact not pick it up from /usr/local/bin (due to the caching, which which would be unaware of).
A summary of the history of which, and the pitfalls of using it, is found here: Why not use "which"? What to use then?
which cmakeandtype -a cmake? – Nov 29 '19 at 13:31whichpoints to/usr/local/bin/cmake;type -areturns two lines, one for each.type -freturns:cmake is hashed (/usr/bin/cmake)– user907323 Nov 29 '19 at 13:34whichsince this is software designed forcshfrom 1979 that does not work well together with shells similar to the Bourne Shell. Rather usetype, as this is built into the shell and knows how your current shell will decide. – schily Nov 29 '19 at 14:21which. If I did, let me know where and I'll correct it. – Kusalananda Nov 29 '19 at 14:47which. – schily Nov 29 '19 at 14:57which. – Kusalananda Nov 29 '19 at 15:10which, hence the link could have been relevant. – user907323 Nov 29 '19 at 15:33