I think you are tying to use classic feature of SharePoint in SharePoint online.
SharePoint online site script editor web part is not available by default. In order to make it available, we need to enable the custom script from the SharePoint Tenant admin center.
You can enable it by going to below URL
_layouts/15/online/TenantSettings.aspx
Now select to allow users to run the custom script for both the radio button for below given Option.
Allow users from running custom script on personal sites.
Allow users from running custom script on self-service created sites)
after this setting You have to wait for 24 hours after that custom script will be enable on your site