`check_estimator` fails when checked after doing `set_output(transform='pandas')` on the instance

### Describe the bug

`sklearn.utils.estimator_checks.check_estimator` fails with a method when `set_output` is called(`<estimator_instance>.set_output(transform='pandas')`), but doesn't fail when it is not called.

I was doing the test on a custom estimator that I had written and after fail, I wanted to check the behaviour on an estimator that is part of sklearn and that's when I get this error. So, I will adopt the fix that I get from this issue.

### Steps/Code to Reproduce
```python
import pandas as pd
from sklearn import preprocessing
from sklearn.datasets import fetch_california_housing
from sklearn.utils.estimator_checks import check_estimator

cal_house = fetch_california_housing(as_frame=True)
cal_house = pd.merge(left=cal_house['data'], right=cal_house['target'], left_index=True, right_index=True)

my_stand_scale = preprocessing.StandardScaler()
my_stand_scale.set_output(transform='pandas')
my_stand_scale.fit_transform(X=cal_house.drop(columns='MedHouseVal', axis=1), y=cal_house.loc[:,'MedHouseVal'])

check_estimator(estimator=my_stand_scale, generate_only=False)
```

### Expected Results

No error is thrown by `check_estimator`

### Actual Results
```pytb
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-12-1f43d30ea78e>](https://localhost:8080/#) in <cell line: 12>()
     10 my_stand_scale.fit_transform(X=cal_house.drop(columns='MedHouseVal', axis=1), y=cal_house.loc[:,'MedHouseVal'])
     11 
---> 12 check_estimator(estimator=my_stand_scale, generate_only=False)

2 frames
[/usr/local/lib/python3.10/dist-packages/sklearn/utils/estimator_checks.py](https://localhost:8080/#) in check_estimator(estimator, generate_only, Estimator)
    631     for estimator, check in checks_generator():
    632         try:
--> 633             check(estimator)
    634         except SkipTest as exception:
    635             # SkipTest is thrown when pandas can't be imported, or by checks

[/usr/local/lib/python3.10/dist-packages/sklearn/utils/_testing.py](https://localhost:8080/#) in wrapper(*args, **kwargs)
    186             with warnings.catch_warnings():
    187                 warnings.simplefilter("ignore", self.category)
--> 188                 return fn(*args, **kwargs)
    189 
    190         return wrapper

[/usr/local/lib/python3.10/dist-packages/sklearn/utils/estimator_checks.py](https://localhost:8080/#) in check_no_attributes_set_in_init(name, estimator_orig)
   3094     # Test for no setting apart from parameters during init
   3095     invalid_attr = set(vars(estimator)) - set(init_params) - set(parents_init_params)
-> 3096     assert not invalid_attr, (
   3097         "Estimator %s should not set any attribute apart"
   3098         " from parameters during init. Found attributes %s."

AssertionError: Estimator StandardScaler should not set any attribute apart from parameters during init. Found attributes ['_sklearn_output_config'].
```
### Versions

```shell
scikit-learn==1.2.2 on Python 3.10.12 on Ubuntu 20.04.6 LTS (or google colab on date this issue was created.)
```

COMMENT:
So I think a fix for this is to make sure we call `set_output` on a given estimator always before running tests, to test the behavior we expect.

Labels: Bug, help wanted, Developer API