Does the predict function in machine learning understand categorical data
This depends somewhat on the model and language (implementation).

First please understand that categorical data is not the same as non-numerical data! Many models can handle categorical data (e.g. regression formats) just fine and some can even handle non-numerical data.

Finally and most important for you feature engineering has to be done on the whole data set before the train/test split. All models can only predict on data that has the exact same input formats as the data it has been trained on!

So yes if you one-hot encoded some column it also needs to be one-hot encoded for the prediction.