@Limit provides a good answer for web applications, but I'd like to answer your question for the general case.
E.G. you have an application, which you entrust with your password so it can sign you into other services. A good example would be your mail client(either on your smartphone or your desktop pc), which must store your username and password in order to authenticate with the mailserver. Another example of applications that do this would be web browsers which can store your login credentials for various websites.
These software agents need access to your plain text password, so the standard solution for keeping a password safe (password hashing) can't be used.
The short answer to your question in this case: You're entirely right, this isn't secure and your credentials can't be reliably protected (assuming you're not asked by the mail client / webbrowser to provide a master password, that is).
The longer answer: Some operating systems provide a kind of password safe, which is basically a file which contains the passwords, but the file is encrypted before storing it on disk.
In order to encrypt and decrypt, the operating system needs a key. It generates a random one and then encrypts this key with the password you use to sign into your operating system user account. Whenever you sign in, the password you entered is used to decrypt the random key. So this adds a layer of security (which can be circumvented by malware, but at least it's not enough to just look at the password file in order to steal your passwords). Of course, if you don't have any sign-in authentication configured for your os user account, this is pointless, because the OS won't have any secret from you to encrypt and decrypt the password file key with.
Operating systems which provide this password safe service for user applications are, as far as I know, in the minority. But there'a a few systems that work almost like that. For example, the KDE desktop environment on Linux provides such a password safe; it's not connected to your system user account password, so you need to provide an additional password, but just once per session. All software agents which use the password safe can then access their respective passwords.
(As an aside: Smartphone operating systems like iOS and Android provide transparent encryption of all your data on the phone. If you enable this, it works exactly like the system I've described for encrypting the password safe - your sign-in secret (e.g. pin code, password) is used to encrypt the master key which encrypts and decrypts the stored data)