Older cruisers and destroyers bought at discount from major powers
If not only the technology, but also geopolitics are similar to the real world historical era, then these nations would be in the sphere of influence of major powers. And if they are both independent and consider going to war with each other, it means they are not fully under the hegemony of one of the major powers, but as the major powers will want to exert some influence in the area, they will use these nations either in proxy wars, or as a projection of power.
As other answers explained, these nations are too small to be able to construct capital ships of the era. However, they could purchase second-rate ships from the major powers. When a major power upgrades the fleet, it will sell some of the older vessels to them. This might even happen at a serious discount, and some vessels might even be gifted, so that the donor Great Power can increase its influence in the area by strengthening its local ally/protectorate.
These nations will then likely end up in the sphere of influence of one major power or another, and the wars between each other might even be proxy wars between the major powers.
What kinds of ships could they have? Take a look at the SMS Emden, which would have been a relatively minor vessel in a battle like the Battle of Jutland, but in East Asia it alone had a really serious effect, and achieved impressive results. So, in an archipelago far from the mainlands of the major powers, an armored cruiser would fill the role of a capital ship, with a couple light or protected cruisers, and up to at most a dozen small destroyers for the bigger nations (here I mean something like the 1893 Daring-class, or the 1903 River-class at most, not giants like the Fletcher) completing the fleet. They would be far too much for them to build, but acquiring such a fleet might be possible by buying (or receiving as "gifts" in exchange for exclusive trade deals) older ships from the major powers.
Then they can complement this fleet with torpedo boats of their own design, which is the only naval vessel they could realistically build themselves.
An interesting example at a smaller scale.
The novel Mathias Sandorf from Jules Verne features an interesting example for a navy of a small island nation. The protagonist founded a small nation on a previously uninhabited and recently purchased private island in the Mediterranean, close to the African coast, in the late 19th century, which gets under attack by pirates organized by the Senusiyya movement. The island's population is only in the few thousands, but as they are fresh settlers, most of them are of military age, and they can muster a defending force of about 500 men.
The islanders have a modern 350-ton steam yacht as their flagship, which was made to order in France, equipped with Hotchkiss revolving cannons, and three small semi-submersible fast torpedo boats of their own design. The attackers have the numerical superiority, coming with a huge fleet mostly composed of small sailing ships, fishing vessels, with a few larger but poorly armed merchant ships, carrying a large landing force to conquer the island. The navy of the defenders cannot stop them entirely from landing troops, but does enough damage to the invading navy that the greatly diminished landing force is finally defeated.
This is a great example of what a small but technologically very advanced island nation can afford: a relatively big ship they purchased in a bigger country, and a few smaller patrol boats they built themselves. And when it comes to fighting, it can involve smaller cargo and fishing vessels pressed into service, usually to land troops or perform boarding actions, as they will lack the firepower to sink enemy vessels quickly.