Scientists have discovered a new species of prehistoric animal that swam in lakes and rivers around 165 million years ago.