Image compression is the process of reducing how many bytes an image needs to store. It is different from resizing. A 4000×3000 photo can be compressed while staying 4000×3000 pixels, and a photo can be resized to 1200×900 while still using a relatively large file size. Many upload problems become easier once you separate those two ideas.
Start with the requirement you actually have
If a website says "maximum 500KB," your first goal is file size. If it says "1080×1080 pixels," your first goal is dimensions. When it gives both requirements, resize or crop to the required dimensions first, then compress the resized copy. This avoids spending bytes on pixels the destination will never display.
Why photographs and graphics compress differently
Photographs contain gradual color changes and irregular detail. JPG and WebP are designed to reduce the data needed for that kind of content, usually with some loss of detail. Logos, screenshots and diagrams often contain flat colors, hard edges and text; PNG can preserve those edges well, but the file may be larger.
What happens when you push the target too low
Strong lossy compression can create blockiness, ringing around edges, smeared texture and soft text. The right target is not simply the smallest number. It is the smallest file that still looks acceptable for the destination.
100KB, 200KB, 500KB or 1MB?
Smaller targets are useful for strict forms and lightweight thumbnails. Larger targets give detailed photographs more room. There is no universal quality level attached to a particular number because two images of the same dimensions can contain very different amounts of visual information.
Keep the original
Compression should create a delivery copy, not replace your only master file. Keep the source image so you can export another version later for print, a different platform, or a less aggressive size limit.