That's called 'data leakage'.
http://machinelearningmastery.com/data-leakage-machine-learn...
http://machinelearningmastery.com/data-leakage-machine-learn...
There's no leakage in either case. The model is learning one thing and you think it's learning another.
It doesn't generalise when the US ship is in Chinese waters, but that's because the system was never "learning" to recognize ships in the first place.