If you don't install perl/python on your system then hackers can't use it (or they would make themselves obvious if they installed it)? I am just trying to understand why these languages are apparently useful for hackers. Seems bash/dos would be more useful.
Not every attack requires running Perl/Python scripts on your machine. Exploiting buffer overflows, SQL injection via a network interface and others have no requirement for Perl/Python. Using those languages can make creation and delivery of the payload much easier
Yes, an attacker could install their own interpreter. Depending upon the level of compromise (rootkit) and the common usage of the system (prod vs test) the installation may or may not be detectable and may or may not be dismissed if detected
These languages were once the new, hot, sexy thing to learn, much like ruby and jquery are now. Many security experts wanted to learn these languages and so used them to create tools.
Today, there are multiple tools that use these languages. This creates some amount of momentum to continuing to use these interpreters.
These interpreters are pre-installed on many operating systems and run pretty consistently on different platforms. This makes development, test, and reuse easier. It also makes exploit easier when victim systems already have the interpreter installed.
These interpreters have many highly useful libraries that provide extremely useful functionality. This makes tool development much easier. Tis functionality may not be as easily available with sh/dos. Especially so, consider that sh/dos relies on other programs to do most of the work, and can provide minimal builtins.
Dos provides very limited scripting capability. It's very difficult to do something really complex with a dos script.
Just like your interpreter of choice may or may not exist, the same may be said of almost any other software. Unix systems don't actually require a shell to operate. Missing the shell makes it more difficult to maintain, but it will still run.
In situations where an interpreter is used on a system, both the interpreter and script may contain vulnerabilities. Hackers may enjoy exploiting these preinstalled vulnerabilities. Well known vulns make it even easier.
There are probably other considerations that make your common interpreter of choice no worse than and probably better than sh or dos, but I am too lazy to write more.
In most cases the hacker has whatever scripting language he/she prefers on their own system. They use that scripting language to build their custom attacks to exploit a vulnerability in a remote exposed service.
You may be under the impression that the hacker uses python/perl to install their program on a remote host. This indicates that the hacker already has control. Unless we're talking about malware/trojans how did the hacker gain access to begin with? That is with their python/perl/whatever script they used to get a remote shell.
From there your remote shell will most likely be either bash or (preferably) powershell. Now you can continue to compromise the target network.
For further reference on why python/perl are popular 'hacking' languages check out this SE question.