FeatureUnion with polars output can error due to duplicate column names

### Describe the bug

FeatureUnion concatenates outputs of its transformers _before_ the `set_output` wrapper renames columns based on `get_feature_names_out` (adding the transformer name prefix). This works with pandas but not polars which does not allow creating a dataframe with duplicate feature names

in addition to the reproducer below, `pytest sklearn/tests/test_pipeline.py::test_feature_union_set_output` fails if we replace "pandas" with "polars" in the test

### Steps/Code to Reproduce

```python
import polars as pl
import pandas as pd
from sklearn.pipeline import FeatureUnion
from sklearn.preprocessing import StandardScaler

df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [1, 2, 3, 4]})
fu = FeatureUnion([("std_1", StandardScaler()), ("std_2", StandardScaler())])
fu.set_output(transform="pandas")
fu.fit_transform(df) # OK

# result:
#
#    std_1__a  std_1__b  std_2__a  std_2__b
# 0 -1.341641 -1.341641 -1.341641 -1.341641
# 1 -0.447214 -0.447214 -0.447214 -0.447214
# 2  0.447214  0.447214  0.447214  0.447214
# 3  1.341641  1.341641  1.341641  1.341641

df = pl.from_pandas(df)
fu.set_output(transform="polars")
fu.fit_transform(df) # ERROR during hstack step as both transformers have output column names ['a', 'b']

# error:
# Traceback (most recent call last):
#     ...
# polars.exceptions.DuplicateError: column with name 'a' has more than one occurrence
```

### Expected Results

dataframe with column names `std_1__a  std_1__b  std_2__a  std_2__b`

### Actual Results
```
Traceback (most recent call last):
  File ".../feature_union.py", line 26, in <module>
    fu.fit_transform(df) # ERROR during hstack step as both transformers have output column names ['a', 'b']
    ~~~~~~~~~~~~~~~~^^^^
  File ".../scikit-learn/sklearn/utils/_set_output.py", line 316, in wrapped
    data_to_wrap = f(self, X, *args, **kwargs)
  File ".../scikit-learn/sklearn/pipeline.py", line 1970, in fit_transform
    return self._hstack(Xs)
           ~~~~~~~~~~~~^^^^
  File ".../scikit-learn/sklearn/pipeline.py", line 2042, in _hstack
    return adapter.hstack(Xs)
           ~~~~~~~~~~~~~~^^^^
  File ".../scikit-learn/sklearn/utils/_set_output.py", line 183, in hstack
    return pl.concat(Xs, how="horizontal")
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.13/site-packages/polars/functions/eager.py", line 254, in concat
    out = wrap_df(plr.concat_df_horizontal(elems))
                  ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
polars.exceptions.DuplicateError: column with name 'a' has more than one occurrence
```

### Versions

```shell
System:
    python: 3.13.7 | packaged by conda-forge | (main, Sep  3 2025, 14:24:46) [Clang 19.1.7 ]
   machine: macOS-15.6.1-arm64-arm-64bit-Mach-O

Python dependencies:
      sklearn: 1.8.dev0
          pip: 25.2
   setuptools: None
        numpy: 2.3.2
        scipy: 1.16.1
       Cython: 3.1.3
       pandas: 2.3.2
   matplotlib: None
       joblib: 1.5.2
threadpoolctl: 3.6.0

Built with OpenMP: True

threadpoolctl info:
       user_api: openmp
   internal_api: openmp
    num_threads: 4
         prefix: libomp
       filepath: /opt/homebrew/Cellar/libomp/20.1.7/lib/libomp.dylib
        version: None
```

COMMENT:
Thanks for the report @jeromedockes. The issue looks similar to https://github.com/scikit-learn/scikit-learn/issues/28260.

A quick fix would be to rename the columns of all Xs before stacking them. We don't really need to care about the new names of the columns since the set_output wrapper will use the columns from `get_feature_names_out` afterwards anyway.

Labels: Bug