If you are not hiring a car, the most important website you will need to find local transport in Wales is:>http://www.traveline.cymru
Also check out the longer distance bus routes in Wales at:> http://www.trawscymru.info/routes/
You say that you would like to roam along the coast. Well, although most parts of the coast are scenic, some areas are not. So, consider heading for the best bits such as Pembrokeshire, the Lleyn peninsula and the Gower peninsula - which is west of Swansea.
I would consider heading maybe for Tenby in south Pembrokeshire first. (On summer Saturdays, 1 direct train leaves London for south Pembrokeshire - otherwise you must change trains en-route). The area west of Tenby - particularly around Stackpole / Bosherston / Manorbier offers fine coastal walks although an area just to the west is closed on weekdays (except in mid summer) as it is a military range known as Castlemartin. Also consider west Pembrokeshire with perhaps St.David’s making a base. To reach here from London, you must take a train to Haverfordwest & then bus. Pembroke has a Castle and another one (ruin) can be found at Carew. Pembrokeshire map:>https://email@example.com,-4.7997097,45011m/data=!3m1!1e3!5m1!1e1
A shorter journey from London is the Gower peninsula. This involves a direct train to Swansea (which is a dump) and then bus onto the peninsula. If doing this, best to head for Rhossilli at the western tip and then start walking east along the south coast. Map of Gower:>https://firstname.lastname@example.org,-4.1127215,19021m/data=!3m1!1e3!5m1!1e1
Also consider the coast of the Lleyn peninsula in NW Wales. To get here, take a train from London (Euston) to Birmingham or Shrewsbury - where you change for one heading for the Cambrian Coast. (Be careful as these trains will be split at Machynleth with one section going to Aberystwyth - you need the section for Pwllheli. If doing this, consider heading for Porthmadog as that is a local transport centre and also has:> www.festrail.co.uk and Portmeirion is nearby. From here, you can reach Caernarfon castle and/or go back down the coast to Harlech castle. You can then go on down the Lleyn peninsula as well if coast is what you want. Map:> https://email@example.com,-4.3532919,41145m/data=!3m1!1e3!5m1!1e1
Pre-book longer trains journeys as turn up and go fares can be expensive. www.nationalrail.co.uk
PS. If going to south Wales, consider a couple of nights in Cardiff - which has a castle in the centre whilst Caerphilly Castle & Castell Coch are just to the north and St.Fagans Castle & museum is an easy bus (32A) ride to the west.