PowerShell, 1313 10 bytes
$f={@($_)*$_}
Usage
PS C:\> 2 | % $f{@($_)*$_}
2
2
And:
PS C:\> 5 | % $f{@($_)*$_}
5
5
5
5
5
By default, PowerShell shows array content one element per line. Running it through the ConvertTo-Json
cmdlet shows it in a more familiar form:
PS C:\> 5 | % $f{@($_)*$_} | ConvertTo-Json -Compress
[5,5,5,5,5]