I had this idea of developing a mobile app that allows users to download videos from twitter and youtube to be able to access them offline.. is this considered illegal? (sorry if my question is in the wrong place)
It is not illegal to write such a program. It is illegal to use such a program, since the TOS Sect. 5.1(C) only allows using their technology:
you agree not to access Content through any technology or means other than the video playback pages of the Website itself, the YouTube Player, or such other means as YouTube may explicitly designate for this purpose
Google Play would also not allow you to disseminate the program. Then the question is whether you might still be liable for helping others infringe on copyright, i.e. vicarious infringement. MGM v. Grokster, 545 U.S. 913 would be a relevant case to consider. The courts held that
One who distributes a device with the object of promoting its use to infringe copyright, as shown by clear expression or other affirmative steps taken to foster infringement, going beyond mere distribution with knowledge of third-party action, is liable for the resulting acts of infringement by third parties using the device, regardless of the device’s lawful uses
This raises a technical question, as to whether there are any non-infringing uses of the app, that is, is this a general program that can be directed at all sorts of online videos (where there are legal uses), or is this aimed just at Twitter & Youtube, anthis only has infringing uses. In contrast, in Sony v. Universal City Studios, 464 U.S. 417 it was found that there were significant non-infringing uses to the VCR, thus Sony would not be vicariously liable. It would be hard to argue that distributing such a program did not have the goal of promoting its use to infringe copyright.