BUG: groupby 2 column then can't set value on multiple columns
### 

- [X] I have checked that this issue has not already been reported.

- [X] I have confirmed this bug exists on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pandas.

- [ ] I have confirmed this bug exists on the master branch of pandas.


### Reproducible Example

```python
import pandas as pd
import numpy as np

def f(df):
    f'{df}'
    df[['c', 'd']]=np.zeros([len(df),2])

df=pd.DataFrame([[1,2],[1,3]],columns=['a','b'])
dfg=df.groupby(['a','b']).apply(f)
```


### Issue Description

1) groupby 2 columns and "apply" a function
2) set value to multiple columns in this "apply" function
3) in the second group invoking this "apply" function, on access of input df, it report an error:
```Length of values (2) does not match length of index (4)```

### Expected Behavior

groupby apply function should not keep changes of index into next iteration

### Installed Versions

INSTALLED VERSIONS
------------------
commit           : 945c9ed766a61c7d2c0a7cbb251b6edebf9cb7d5
python           : 3.9.7.final.0
python-bits      : 64
OS               : Windows
OS-release       : 10
Version          : 10.0.17763
machine          : AMD64
processor        : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
byteorder        : little
LC_ALL           : None
LANG             : zh_CN
LOCALE           : Chinese (Simplified)_China.936

pandas           : 1.3.4
numpy            : 1.21.3
pytz             : 2021.3
dateutil         : 2.8.2
pip              : 21.3.1
setuptools       : 57.4.0
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : None
IPython          : 7.29.0
pandas_datareader: None
bs4              : None
bottleneck       : None
fsspec           : None
fastparquet      : None
gcsfs            : None
matplotlib       : None
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pyxlsb           : None
s3fs             : None
scipy            : 1.7.1
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
xlwt             : None
numba            : None