As data source provider has it’s own copy of template file engine that is separate from the Terraform itself. The engine depends on the version of Terraform that the provider was compiled with and not the one run on your system.

Using templatefile(path, vars) function will give you more consistent results as it depends on the version of Terraform you are using.