Why do I get different result when executing with Script Editor or osascript and different computers?

I have two machines, A and B and this (simplified) script:

set myUrl to URL of active tab of front window as text
set filename to the last text item of www

set sh to the contents of {¬
	"cd", quoted form of the POSIX path of HFSPath, ";", ¬
	"curl --remote-name", ¬
	"--url", quoted form of www} as text

try
	using terms from scripting additions
		do shell script sh
	end using terms from
on error E
	return E
end try

HFSPath is "/tmp" and the URL is https://www.google.com/recaptcha/api2/payload/audio.mp3?p=06ADUVZwDs59yB8A_RpC-9TSQx4kP1wMWv8qUgN8oStI9qH__3BPRrhTtKUUTmB8wATiyBzjMAIUpHMQwZtA_FY7bJWvqn2A_ERYHkf-17Wk97ikKx2g1vpIB2jhiYnOUnq0SGQiUrugbx3AncLWPUpUK0-Owq7n_I1Anfi-3LdWnJBS74Xn1xHPV_uHclYxyyoZ4mUWjjyjUdtv9ReC7ETGqCIgQy-rjAcA&k=6Lf1KHQUAAAAAFNKEX1hdSWCS3mRMv4FlFaNslaD

When executing this, the log in Script Editor returns this entry when the shell script is executed:

do shell script "cd '/tmp' ; curl --remote-name --url 'https://www.google.com/recaptcha/api2/payload/audio.mp3?p=06ADUVZwDs59yB8A_RpC-9TSQx4kP1wMWv8qUgN8oStI9qH__3BPRrhTtKUUTmB8wATiyBzjMAIUpHMQwZtA_FY7bJWvqn2A_ERYHkf-17Wk97ikKx2g1vpIB2jhiYnOUnq0SGQiUrugbx3AncLWPUpUK0-Owq7n_I1Anfi-3LdWnJBS74Xn1xHPV_uHclYxyyoZ4mUWjjyjUdtv9ReC7ETGqCIgQy-rjAcA&k=6Lf1KHQUAAAAAFNKEX1hdSWCS3mRMv4FlFaNslaD'"

Now the weird thing. When I execute this code in Script Editor on A the resulting filename is audio.mp3 (a string you find in the middle of the URL). The result is the same if I execute it using osascript on B BUT if I run this code using Script Editor on B the filename becomes audio.mp3?p=06ADUVZwDs59yB8A_RpC-9TSQx4kP1wMWv8qUgN8oStI9qH__3BPRrhTtKUUTmB8wATiyBzjMAIUpHMQwZtA_FY7bJWvqn2A_ERYHkf-17Wk97ikKx2g1vpIB2jhiYnOUnq0SGQiUrugbx3AncLWPUpUK0-Owq7n_I1Anfi-3LdWnJBS74Xn1xHPV_uHclYxyyoZ4mUWjjyjUdtv9ReC7ETGqCIgQy-rjAcA&k=6Lf1KHQUAAAAAFNKEX1hdSWCS3mRMv4FlFaNslaD - which fails because the filename is too long.

When looking closer at this (I mostly copied the code from an example), I am surprised that it works (that is, the output file is named audio.mp3) on A and with osascript on B. OTOH, executing the literal curl-command above generates a file just called audio.mp3.

Why does the result in Script Editor on B differ from Script Editor on A and osascript on B?